<template>
  <div class="box">
    <div class="box-left">
      <div class="box-left-content">
        <h1 style="color: white">Weblog 博客登录</h1>
        <img class="img" src="../assets/login-logo.png" alt="" />
      </div>
    </div>
    <div class="box-right">
      <div class="box-right-content">
        <h2>欢迎回来</h2>
        <p>——————账号密码登录——————</p>
        <el-form
          :model="ruleForm"
          :rules="rules"
          ref="ruleForm"
          label-width="100px"
          class="demo-ruleForm"
        >
          <el-form-item prop="username">
            <el-input
              placeholder="请输入内容"
              v-model="ruleForm.username"
              clearable
            ></el-input>
          </el-form-item>
          <br />
          <el-form-item prop="password">
            <el-input
              placeholder="请输入密码"
              v-model="ruleForm.password"
              show-password
            ></el-input>
          </el-form-item>
          <br />
          <el-button type="primary" round @click="submitForm('ruleForm')"
            >主要按钮</el-button
          >
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
import { Login } from '../../../my-login/src/units/api';
export default {
  data() {
    return {
      ruleForm: {
        username: "",
        password: "",
      },

      rules: {
        username: [{ required: true, message: "请输入用户", trigger: "blur" }],
        password: [{ required: true, message: "请输入密码", trigger: "blur" }],
      },
    };
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate(async (valid) => {
        if (valid) {
          let res = await Login(this.ruleForm)
          console.log(res);
           this.$refs[formName].resetFields();
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
  },
};
</script>

<style scoped>
@import "../css/login.css";
</style>